<?php

	namespace Aspic\Model;
	
	use Aspic as A;
	
	/**
	* @Author Mallory Dessaintes <mdessaintes@gmail.com>
	* @version 1.0
	*/
	
	/**
	* Base model class.  All models of the application should extends it
	* 
	* @Author Mallory Dessaintes <mdessaintes@gmail.com>
	* @version 1.0
	*/
	abstract class AbstractModel extends A\Service\AbstractService {
		const INIT_METHOD_NAME = 'init';
		
		protected static $_initDone = false;
		
		public function __construct() {
			if(!self::$_initDone) {
				static::doInitData();
			}
			
			$this->{self::INIT_METHOD_NAME}();
		}
		
		protected function doInitData() {
			static::initData();
			
			self::$_initDone = true;
		}
		
		/**
		* This method have to load pre-requisite for child class.
		* It is loaded only one time, at the first use of the class.
		* Init example : Database connection
		*/
		protected static function initData() {
			static::$db = null;
		}
		
		protected function init() {
			
		}
		
	}	
	
?>